package com.dkm.dkmproject.action;


import com.dkm.dkmproject.domain.RecordTb;
import com.dkm.dkmproject.domain.WalletTb;
import com.dkm.dkmproject.service.IRecordTbService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 提现记录表 前端控制器
 * </p>
 *
 * @author 周佳佳
 * @since 2020-04-26
 */
@RestController
@RequestMapping("/dkm.dkmproject/recordTb")
@Api(description="提现记录接口文档")
public class RecordTbController {

    @Autowired
    IRecordTbService recordTbService;

    /**
     * 根据用户id查询钱包提现记录
     * @param userId
     * @return
     */
    @ApiOperation(value = " 根据用户id查询钱包提现记录", notes = "成功则返回数据，失败返回空")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", dataType = "Integer", name = "reId", value = "主键"),
            @ApiImplicitParam(paramType = "query", dataType = "Integer", name = "userId", value = "用户id",required = true),
            @ApiImplicitParam(paramType = "query", dataType = "BigDecimal", name = "reMoney", value = "提现金额"),
            @ApiImplicitParam(paramType = "query", dataType = "Date", name = "reDate", value = "提现时间")
    })
    @ApiResponses({
            @ApiResponse(code = 401, message = "没有权限"),
            @ApiResponse(code = 403, message = "服务器拒绝请求"),
            @ApiResponse(code = 404, message = "请求路径没有或页面跳转路径不对"),
            @ApiResponse(code = 500, message = "后台报错"),
            @ApiResponse(code = 200, message = "返回成功")
    })
    @GetMapping("/selectList")
    public List<RecordTb> selectList(Integer userId){
        if(!StringUtils.isEmpty(userId)){
            List<RecordTb> list=recordTbService.findByUserId(userId);
            return list;
        }else{
            return null;
        }
    }
    @RequestMapping("selectAllTwo")
    @ResponseBody
    public Map<String,Object> selectAll(@RequestParam("page") Integer pageNum , @RequestParam("limit") Integer pageSize
    ,String userName){
        Map<String,Object> map=new HashMap<>();

        map.put("code",0);
        map.put("msg","");
        map.put("data",recordTbService.selectAllTwo(pageNum,pageSize,userName));
        map.put("count",recordTbService.selectCountOne(userName));
        return map;
    }
}
